package tc.jv.task5;

import java.util.Iterator;

public class ArrayVector extends tc.jv.task4.ArrayVector implements Iterable<Double>
{

	/**
	 * 
	 */
	private static final long serialVersionUID = 3559342598369918336L;

	// CONSTRUCTORS
	
	public ArrayVector()
	{
		super();
	}
	
	public ArrayVector(int size)
	{
		super(size);
	}
	
	public ArrayVector(double ... values)
	{
		super(values.length);
		data = values.clone();
	}

	// METHODS
	
	@Override
	public Iterator<Double> iterator()
	{
		Iterator<Double> iterator = new Iterator<Double>()
		{

			private int index = 0;
			
			@Override
			public boolean hasNext()
			{
				return index != size();
			}

			@Override
			public Double next()
			{
				return data[index++];
			}

			@Override
			public void remove()
			{
				ArrayVector.this.remove(index);
			}
			
		};
		
		return iterator;
	}
	
}
